$.extend(validatePrompt, {
	oldPassword : {
		onFocus : "请输入旧密码",
		succeed : "1",
		isNull : "请输入旧密码",
		error : {
			badLength : "1",
			badFormat : "2",
			simplePwd : "3"
		}
	},
	password : {
		onFocus : "6-20位字符，可使用字母、数字或符号的组合",
		succeed : "",
		isNull : "请输入新密码",
		error : {
			badLength : "密码长度只能在6-20位字符之间",
			badFormat : "密码只能由英文、数字及标点符号组成",
			simplePwd : "密码太弱，有被盗风险，建议设置多种字符组成的复杂密码"
		}
	},
	confirmPassword : {
		onFocus : "请再次输入新密码",
		succeed : "",
		isNull : "请输入新密码",
		error : {
			badLength : "密码长度只能在6-20位字符之间",
			badFormat2 : "两次输入密码不一致",
			badFormat1 : "密码只能由英文、数字及标点符号组成"
		}
	}
});

$.extend(validateFunction, {
	oldPassword : function(option) {
		validateSettings.succeed.run(option);
	},
	password : function(option) {

		var str1 = option.value;
		var str2 = $("#confirmPassword").val();
		var format = validateRules.isPwd(option.value);
		var length = validateRules.betweenLength(option.value, 6, 20);
		$("#pwdstrength").hide();
		if (!length && format) {
			validateSettings.error.run(option, option.prompts.error.badLength);
		} else if (!length && !format) {
			validateSettings.error.run(option, option.prompts.error.badFormat);
		} else if (length && !format) {
			validateSettings.error.run(option, option.prompts.error.badFormat);
		} else {
			validateSettings.succeed.run(option);
			validateFunction.pwdstrength();
		}
		if (str2 == str1) {
			$("#confirmPassword").focus();
		}
	},
	confirmPassword : function(option) {
		var str1 = option.value;
		var str2 = $("#password").val();
		var length = validateRules.betweenLength(option.value, 6, 20);
		var format2 = validateRules.isPwd2(str1, str2);
		var format1 = validateRules.isPwd(str1);
		if (!length) {
			validateSettings.error.run(option, option.prompts.error.badLength);
		} else {
			if (!format1) {

				validateSettings.error.run(option,
						option.prompts.error.badFormat1);
			} else {
				if (!format2) {
					validateSettings.error.run(option,
							option.prompts.error.badFormat2);
				} else {
					validateSettings.succeed.run(option);
				}
			}
		}
	},
	submit_validate : function() {
		$("#oldPassword").jdValidate(validatePrompt.oldPassword,
				validateFunction.oldPassword, true)
		$("#password").jdValidate(validatePrompt.password,
				validateFunction.password, true)
		$("#confirmPassword").jdValidate(validatePrompt.confirmPassword,
				validateFunction.confirmPassword, true);

		return validateFunction.FORM_submit([ "#oldPassword", "#password",
				"#confirmPassword" ]);
	}
});

$("#oldPassword").jdValidate(validatePrompt.oldPassword,
		validateFunction.oldPassword);
$("#password").jdValidate(validatePrompt.password, validateFunction.password);
$("#confirmPassword").jdValidate(validatePrompt.confirmPassword,
		validateFunction.confirmPassword);

$("#updateEntPsd").click(function() {
	var flag = validateFunction.submit_validate();
	if (flag) {

		$("#updateEntPassword").submit();
	}
})
